{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "目录\n",
    "\n",
    "* [随机森林-分类任务](#随机森林-分类任务)\n",
    "* [随机森林-特征重要性](#随机森林-特征重要性)\n",
    "* [随机森林-回归任务](#随机森林-回归任务)\n",
    "\n",
    "# 随机森林-分类任务\n",
    "使用随机森林完成鸢尾花分类任务"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(150, 4) (150,)\n",
      "Class labels: [0 1 2]\n",
      "(105, 2) (105,)\n"
     ]
    }
   ],
   "source": [
    "from sklearn import datasets\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.ensemble import RandomForestClassifier\n",
    "import numpy as np\n",
    "\n",
    "from matplotlib.colors import ListedColormap\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "iris = datasets.load_iris()\n",
    "print(iris['data'].shape, iris['target'].shape) # (150, 4) (150,)\n",
    "X = iris.data[:,[2,3]]\n",
    "y = iris.target\n",
    "print('Class labels:', np.unique(y))\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1, stratify=y)\n",
    "print(X_train.shape, y_train.shape)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "训练，并绘制分类决策边界："
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [],
   "source": [
    "\n",
    "def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):\n",
    "     # setup marker generator and color map\n",
    "     markers = ('s', 'x', 'o', '^', 'v')\n",
    "     colors = ('red', 'blue', 'lightgreen', 'gray', 'cyan')\n",
    "     cmap = ListedColormap(colors[:len(np.unique(y))])\n",
    "\n",
    "     # plot the decision surface\n",
    "     x1_min, x1_max = X[:, 0].min() - 1, X[:, 0].max() + 1\n",
    "     x2_min, x2_max = X[:, 1].min() - 1, X[:, 1].max() + 1\n",
    "     xx1, xx2 = np.meshgrid(np.arange(x1_min, x1_max, resolution),\n",
    "                            np.arange(x2_min, x2_max, resolution))\n",
    "     Z = classifier.predict(np.array([xx1.ravel(), xx2.ravel()]).T)\n",
    "     Z = Z.reshape(xx1.shape)\n",
    "     plt.contourf(xx1, xx2, Z, alpha=0.3, cmap=cmap)\n",
    "     plt.xlim(xx1.min(), xx1.max())\n",
    "     plt.ylim(xx2.min(), xx2.max())\n",
    "\n",
    "     for idx, cl in enumerate(np.unique(y)):\n",
    "         plt.scatter(x=X[y == cl, 0], y=X[y == cl, 1],\n",
    "         alpha=0.8, c=colors[idx],\n",
    "         marker=markers[idx], label=cl,\n",
    "         edgecolor='black')\n",
    "\n",
    "     # highlight test samples\n",
    "     if test_idx:\n",
    "         # plot all samples\n",
    "         X_test, y_test = X[test_idx, :], y[test_idx]\n",
    "         plt.scatter(X_test[:, 0], X_test[:, 1],\n",
    "                     c='', edgecolor='black', alpha=1.0,\n",
    "                     linewidth=1, marker='o',\n",
    "                     s=100, label='test set')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:31: MatplotlibDeprecationWarning: Using a string of single character colors as a color sequence is deprecated since 3.2 and will be removed two minor releases later. Use an explicit list instead.\n"
     ]
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEGCAYAAAB7DNKzAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy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Fwp5WQ6VlMptcu0EN6fSikv051ALYyTuo4opRyVUp8rpQ4qpU4opaabZrKn9/qPXMP0+k6l1HjT3hrnlFINTa87KaWWmvYGWaWUOqCUqqWUGgc4mmJaYGreWik1w7Qvx2bTTHUhnpgkCvEsKwv8rLUuD4QAb5rWtpoCdNda1wRmA2O11ssBP6C31rqa1joSmKq1rm3aU8QRSNe+EmldI8kpNlrrOsC7wBem194E7mutKwAjgZoAWuvhQKQppt6mc0sDP2mtKwIPgG7/9RcjRFK5ZgkPIZ7AVa31XtPj+cDbwCagErDFdINgDdxI4/1NlVIfAU5APuAksC4d1y37mGskLL54CPA1PX4e+BFAa31CKXXMTPuXtdZHUmlDiCciiUI8y1KuX6MBBZzUWpvdSlMp5QD8jHH3t6tKqVGAQzqv+7hrRJu+x/Nk/49GJ3kcj/FuR4gnJl1P4llWNMneyr0wbp96FvBMeF0pZauUqmg6JxRwNT1OSAp3Tft1/JfRTOaukZa9wEum8ysAlZMcizV1ZwmRKSRRiGfZWYyb8ZwG8mLc+CYG44f+eKXUUeAIUN90/m/ANNNKutHADIzLbv+JcZn7dHnMNdLyM8bkcgoYg7GbK9h0bDpwLEkxW4gMJavHimeSaWvX9aZCdLZnWj7dVmsdpZQqCWwFypqSjhCZSmoUQuQMTsAOUxeTAt6UJCGyitxRCCGEMEtqFEIIIcySRCGEEMIsSRRCCCHMkkQhhBDCLEkUQgghzPo/oikQTyYP6Z4AAAAASUVORK5CYII=\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "forest = RandomForestClassifier(criterion='gini', # 划分准则\n",
    "\t\t\t\t\t\t\t\tn_estimators=25, # 25个基学习器（决策树）\n",
    "\t\t\t\t\t\t\t\trandom_state=1,\n",
    "\t\t\t\t\t\t\t\tn_jobs=2) # 并行执行\n",
    "forest.fit(X_train, y_train)\n",
    "X_combined = np.vstack((X_train, X_test))\n",
    "y_combined = np.hstack((y_train, y_test))\n",
    "plot_decision_regions(X_combined, y_combined, classifier=forest, test_idx=range(105,150))\n",
    "plt.xlabel('petal length')\n",
    "plt.ylabel('petal width')\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 随机森林-特征重要性\n",
    "使用随机森林获得特征重要性\n",
    "\n",
    "数据集：白酒数据，共有13个特征\n",
    "\n",
    "使用RandomForestClassifier训练，然后调用feature_importances_属性获得特征重要性："
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Class labels [1 2 3]\n",
      "numbers of features: 13\n"
     ]
    },
    {
     "data": {
      "text/plain": "   Class label  Alcohol  Malic acid   Ash  Alcalinity of ash  Magnesium  \\\n0            1    14.23        1.71  2.43               15.6        127   \n1            1    13.20        1.78  2.14               11.2        100   \n2            1    13.16        2.36  2.67               18.6        101   \n3            1    14.37        1.95  2.50               16.8        113   \n4            1    13.24        2.59  2.87               21.0        118   \n\n   Total phenols  Flavanoids  Nonflavanoid phenols  Proanthocyanins  \\\n0           2.80        3.06                  0.28             2.29   \n1           2.65        2.76                  0.26             1.28   \n2           2.80        3.24                  0.30             2.81   \n3           3.85        3.49                  0.24             2.18   \n4           2.80        2.69                  0.39             1.82   \n\n   Color intensity   Hue  OD280/OD315 of diluted wines  Proline  \n0             5.64  1.04                          3.92     1065  \n1             4.38  1.05                          3.40     1050  \n2             5.68  1.03                          3.17     1185  \n3             7.80  0.86                          3.45     1480  \n4             4.32  1.04                          2.93      735  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Class label</th>\n      <th>Alcohol</th>\n      <th>Malic acid</th>\n      <th>Ash</th>\n      <th>Alcalinity of ash</th>\n      <th>Magnesium</th>\n      <th>Total phenols</th>\n      <th>Flavanoids</th>\n      <th>Nonflavanoid phenols</th>\n      <th>Proanthocyanins</th>\n      <th>Color intensity</th>\n      <th>Hue</th>\n      <th>OD280/OD315 of diluted wines</th>\n      <th>Proline</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1</td>\n      <td>14.23</td>\n      <td>1.71</td>\n      <td>2.43</td>\n      <td>15.6</td>\n      <td>127</td>\n      <td>2.80</td>\n      <td>3.06</td>\n      <td>0.28</td>\n      <td>2.29</td>\n      <td>5.64</td>\n      <td>1.04</td>\n      <td>3.92</td>\n      <td>1065</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>1</td>\n      <td>13.20</td>\n      <td>1.78</td>\n      <td>2.14</td>\n      <td>11.2</td>\n      <td>100</td>\n      <td>2.65</td>\n      <td>2.76</td>\n      <td>0.26</td>\n      <td>1.28</td>\n      <td>4.38</td>\n      <td>1.05</td>\n      <td>3.40</td>\n      <td>1050</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1</td>\n      <td>13.16</td>\n      <td>2.36</td>\n      <td>2.67</td>\n      <td>18.6</td>\n      <td>101</td>\n      <td>2.80</td>\n      <td>3.24</td>\n      <td>0.30</td>\n      <td>2.81</td>\n      <td>5.68</td>\n      <td>1.03</td>\n      <td>3.17</td>\n      <td>1185</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1</td>\n      <td>14.37</td>\n      <td>1.95</td>\n      <td>2.50</td>\n      <td>16.8</td>\n      <td>113</td>\n      <td>3.85</td>\n      <td>3.49</td>\n      <td>0.24</td>\n      <td>2.18</td>\n      <td>7.80</td>\n      <td>0.86</td>\n      <td>3.45</td>\n      <td>1480</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>1</td>\n      <td>13.24</td>\n      <td>2.59</td>\n      <td>2.87</td>\n      <td>21.0</td>\n      <td>118</td>\n      <td>2.80</td>\n      <td>2.69</td>\n      <td>0.39</td>\n      <td>1.82</td>\n      <td>4.32</td>\n      <td>1.04</td>\n      <td>2.93</td>\n      <td>735</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.ensemble import RandomForestClassifier\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "cwd = '/home/xijian/pycharm_projects/Magic-NLPer/MachineLearning/'\n",
    "data_dir = cwd+'RandomForest随机森林/data/'\n",
    "\n",
    "# Wine dataset and rank the 13 features by their respective importance measures\n",
    "df_wine = pd.read_csv(data_dir+'wine.data',\n",
    "                      header=None,\n",
    "                      names=['Class label', 'Alcohol', 'Malic acid', 'Ash', 'Alcalinity of ash', 'Magnesium',\n",
    "                               'Total phenols', 'Flavanoids', 'Nonflavanoid phenols', 'Proanthocyanins', 'Color intensity',\n",
    "                               'Hue', 'OD280/OD315 of diluted wines', 'Proline'])\n",
    "print('Class labels', np.unique(df_wine['Class label']))\n",
    "print('numbers of features:', len(df_wine.keys())-1)\n",
    "df_wine.head()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "data": {
      "text/plain": "(124, 13)"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 划分训练集测试集\n",
    "X, y = df_wine.iloc[:, 1:].values, df_wine.iloc[:, 0].values\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0, stratify=y)\n",
    "X_train.shape"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13\n"
     ]
    },
    {
     "data": {
      "text/plain": "array([0.11535953, 0.02485979, 0.01367936, 0.0206145 , 0.03254997,\n       0.04019533, 0.18793917, 0.01096301, 0.02611948, 0.13488692,\n       0.06345939, 0.13440744, 0.19496612])"
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "feat_labels = df_wine.columns[1:]\n",
    "forest = RandomForestClassifier(n_estimators=200, random_state=1)\n",
    "forest.fit(X_train, y_train)\n",
    "importances = forest.feature_importances_\n",
    "print(len(importances))\n",
    "importances"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "data": {
      "text/plain": "array([12,  6,  9, 11,  0, 10,  5,  4,  8,  1,  3,  2,  7])"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"\"\"\n",
    "numpy.argsort(a, axis=-1, kind=’quicksort’, order=None)\n",
    "功能: 将矩阵a在指定轴axis上排序，并返回排序后的下标\n",
    "参数: a:输入矩阵， axis:需要排序的维度\n",
    "返回值: 输出排序后的下标\n",
    "\"\"\"\n",
    "indices = np.argsort(importances)[::-1] # 取反后是从大到小\n",
    "indices"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 1) Proline                        0.194966\n",
      " 2) Flavanoids                     0.187939\n",
      " 3) Color intensity                0.134887\n",
      " 4) OD280/OD315 of diluted wines   0.134407\n",
      " 5) Alcohol                        0.115360\n",
      " 6) Hue                            0.063459\n",
      " 7) Total phenols                  0.040195\n",
      " 8) Magnesium                      0.032550\n",
      " 9) Proanthocyanins                0.026119\n",
      "10) Malic acid                     0.024860\n",
      "11) Alcalinity of ash              0.020615\n",
      "12) Ash                            0.013679\n",
      "13) Nonflavanoid phenols           0.010963\n"
     ]
    }
   ],
   "source": [
    "for i in range(X_train.shape[1]):\n",
    "    print(\"%2d) %-*s %f\" % (i + 1, 30, feat_labels[indices[i]], importances[indices[i]]))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZwAAAEYCAYAAABoYED3AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAv6UlEQVR4nO3dd5xkVZnG8d8DgsQBFQQFBEVAEEUQREUF1ogJTAgKJgwYEBfDsmsEd1eFNS1rQhQRDAQRUQEBA0FRnJE4iIqAJFFQJCsCz/5xbnXX1FR319D33uqqeb6fz3ym697q+56euV3vveee8x7ZJiIiomnLDLsBERGxdEjCiYiIViThREREK5JwIiKiFUk4ERHRiiSciIhoRRJORES0IgknhkbSlZLulHRb15+H1nDMZ9TVxgHifUjSUW3Fm46k10g6e9jtiJhKEk4M2wtsr9L157phNkbS/YYZ/74a1XbH0iUJJ+YcSatJ+pKkP0q6VtJ/Slq22rehpB9J+oukGyV9TdLq1b4jgYcB363ult4jaQdJ1/Qcf+IuqLpDOU7SUZJuAV4zXfwB2m5Jb5H0O0m3Svpw1eafSbpF0jGSlq/eu4OkayT9R/WzXCnplT3/Dl+VdIOkP0h6n6Rlqn2vkfRTSZ+U9BfgaODzwJOqn/1v1fueJ+m8KvbVkj7UdfwNqva+WtJVVRve27V/2aptv69+lgWS1qv2PUrSaZL+Kuk3kn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qIV6ZePCZLWk/RNSWdJ+o9qsEBn3wlDbFpEjIEknOj2ZeAnwD7AQ4AzqnVxANYfVqMiYjxk0EB0W9P256uv95G0B3CmpBcyOWItIuI+ScKJbstJWsH23wFsHyXpesok0JWH27SIGHXpUotuhwHbdm+wfTrwMuDiobQoIsZGRqlFREQrcocTi5C0o6TjJS2s/hwnaYdhtysiRl8STkyQ9DzKSLXvAq8AXgmcBHw5FaMjYrbSpRYTJP0E2Nf2BT3bHwscYnv7oTQsIsZC7nCi29q9yQbA9oXAWkNoT0SMkSSc6Hb7fdwXETGjzMOJbhtKOrHPdgGPaLsxETFe8gwnJkia9hmN7TPaaktEjJ8knFiMpBWAR1YvL+tUHoiImI08w4kJku4n6SDgGuAI4KvA1ZIO6q4cHRFxXyThRLeDgQcCD7f9eNtbARsCqwP/M8yGRcToS5daTJD0O2Bj95wUkpYFLrW90XBaFhHjIHc40c29yabaeA9ZniAiZikJJ7pdIulVvRurdXEuHUJ7ImKMpEstJkhaBzgeuBNYUG3eGlgReJHta4fVtogYfUk4sRhJ/wI8unp5ie0fDrM9ETEeknAiIqIVeYYTERGtSMKJiIhWJOFEREQrknAiIqIV/w+Md1XWjyQ8ggAAAABJRU5ErkJggg==\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.title('Feature Importance')\n",
    "plt.bar(range(X_train.shape[1]), importances[indices], align='center')\n",
    "plt.xticks(range(X_train.shape[1]), feat_labels[indices], rotation=90)\n",
    "plt.xlim([-1, X_train.shape[1]])\n",
    "plt.tight_layout()\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 随机森林-回归任务\n",
    "\n",
    "数据集：房价预测"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "data": {
      "text/plain": "      CRIM    ZN  INDUS  CHAS    NOX     RM   AGE     DIS  RAD    TAX  \\\n0  0.00632  18.0   2.31     0  0.538  6.575  65.2  4.0900    1  296.0   \n1  0.02731   0.0   7.07     0  0.469  6.421  78.9  4.9671    2  242.0   \n2  0.02729   0.0   7.07     0  0.469  7.185  61.1  4.9671    2  242.0   \n3  0.03237   0.0   2.18     0  0.458  6.998  45.8  6.0622    3  222.0   \n4  0.06905   0.0   2.18     0  0.458  7.147  54.2  6.0622    3  222.0   \n\n   PTRATIO       B  LSTAT  MEDV  \n0     15.3  396.90   4.98  24.0  \n1     17.8  396.90   9.14  21.6  \n2     17.8  392.83   4.03  34.7  \n3     18.7  394.63   2.94  33.4  \n4     18.7  396.90   5.33  36.2  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>CRIM</th>\n      <th>ZN</th>\n      <th>INDUS</th>\n      <th>CHAS</th>\n      <th>NOX</th>\n      <th>RM</th>\n      <th>AGE</th>\n      <th>DIS</th>\n      <th>RAD</th>\n      <th>TAX</th>\n      <th>PTRATIO</th>\n      <th>B</th>\n      <th>LSTAT</th>\n      <th>MEDV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>0.00632</td>\n      <td>18.0</td>\n      <td>2.31</td>\n      <td>0</td>\n      <td>0.538</td>\n      <td>6.575</td>\n      <td>65.2</td>\n      <td>4.0900</td>\n      <td>1</td>\n      <td>296.0</td>\n      <td>15.3</td>\n      <td>396.90</td>\n      <td>4.98</td>\n      <td>24.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>0.02731</td>\n      <td>0.0</td>\n      <td>7.07</td>\n      <td>0</td>\n      <td>0.469</td>\n      <td>6.421</td>\n      <td>78.9</td>\n      <td>4.9671</td>\n      <td>2</td>\n      <td>242.0</td>\n      <td>17.8</td>\n      <td>396.90</td>\n      <td>9.14</td>\n      <td>21.6</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0.02729</td>\n      <td>0.0</td>\n      <td>7.07</td>\n      <td>0</td>\n      <td>0.469</td>\n      <td>7.185</td>\n      <td>61.1</td>\n      <td>4.9671</td>\n      <td>2</td>\n      <td>242.0</td>\n      <td>17.8</td>\n      <td>392.83</td>\n      <td>4.03</td>\n      <td>34.7</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0.03237</td>\n      <td>0.0</td>\n      <td>2.18</td>\n      <td>0</td>\n      <td>0.458</td>\n      <td>6.998</td>\n      <td>45.8</td>\n      <td>6.0622</td>\n      <td>3</td>\n      <td>222.0</td>\n      <td>18.7</td>\n      <td>394.63</td>\n      <td>2.94</td>\n      <td>33.4</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0.06905</td>\n      <td>0.0</td>\n      <td>2.18</td>\n      <td>0</td>\n      <td>0.458</td>\n      <td>7.147</td>\n      <td>54.2</td>\n      <td>6.0622</td>\n      <td>3</td>\n      <td>222.0</td>\n      <td>18.7</td>\n      <td>396.90</td>\n      <td>5.33</td>\n      <td>36.2</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.ensemble import RandomForestRegressor\n",
    "from sklearn.metrics import mean_squared_error\n",
    "\n",
    "df = pd.read_csv(data_dir+'housing.data.txt',\n",
    "                 header=None,\n",
    "                 sep='\\s+',\n",
    "                 names= ['CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT', 'MEDV'])\n",
    "df.head()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(404, 13) (404,)\n"
     ]
    }
   ],
   "source": [
    "# 划分数据集\n",
    "X = df.iloc[:, :-1].values\n",
    "y = df['MEDV'].values\n",
    "X_train, X_test, y_train, y_test =train_test_split(X, y, test_size=0.2, random_state=1)\n",
    "print(X_train.shape, y_train.shape)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MSE train: 1.237, test: 8.916\n"
     ]
    }
   ],
   "source": [
    "forest = RandomForestRegressor(n_estimators=100, criterion='mse', random_state=1, n_jobs=-1)\n",
    "forest.fit(X_train, y_train) # 训练\n",
    "\n",
    "y_train_pred = forest.predict(X_train)\n",
    "y_test_pred = forest.predict(X_test)\n",
    "print('MSE train: %.3f, test: %.3f' % (mean_squared_error(y_train, y_train_pred), mean_squared_error(y_test, y_test_pred)))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}